﻿// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone

namespace UnitTest.Components;

public class PopoverTest : BootstrapBlazorTestBase
{
    [Fact]
    public void Content_Ok()
    {
        var cut = Context.RenderComponent<Popover>(pb =>
        {
            pb.Add(a => a.Title, "test_popover");
            pb.Add(a => a.Content, "test_content");
        });
        Assert.Contains("data-bs-placement=\"top\" data-bs-custom-class=\"shadow\" data-bs-trigger=\"focus hover\"", cut.Markup);
        Assert.Contains("data-bs-original-title=\"test_popover\"", cut.Markup);

        cut.SetParametersAndRender(pb =>
        {
            pb.Add(a => a.Title, "test");
            pb.Add(a => a.Content, "test");
        });
        Assert.Contains("data-bs-original-title=\"test\"", cut.Markup);
    }

    [Fact]
    public void ShowShadow_OK()
    {
        var cut = Context.RenderComponent<Popover>(pb =>
        {
            pb.Add(a => a.Content, "test_content");
            pb.Add(a => a.ShowShadow, false);
        });
        Assert.DoesNotContain("data-bs-custom-class=\"shadow\"", cut.Markup);
    }

    [Fact]
    public void Template_OK()
    {
        var cut = Context.RenderComponent<Popover>(pb =>
        {
            pb.Add(a => a.Template, builder => builder.AddContent(0, "custom-template"));
        });
        Assert.Contains("<template>", cut.Markup);
    }
}
